<template>
    <main>
        <div class="light"></div>
        <figure>
            <div class="text">
                <span></span>
                <span></span>
                <span></span>
            </div>
            <span class="shadow"></span>
        </figure>
    </main>
</template>

<script setup>

</script>

<style lang="scss" scoped>
main {
    --text: '404错误 当前页面不存在哦';
    --hue: 220deg;
    --spin: 25deg;
    --light-color: #ffeab1;
    --perspective: 80vmin;
    --stripe: .3em;
    --stripe-angle: -35deg;

    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-image: linear-gradient(to bottom, #383838, #3c3c3c 50%, #2f2f2f 60%, #0b0e13);
    font-size: 17.5vmin;

    .light {
        display: block;
        position: absolute;
        top: 0;
        left: 50%;
        width: 90%;
        height: 60%;
        min-height: 6em;
        transform: translateX(-50%) translateY(-1em);
        z-index: 1;
        mix-blend-mode: screen;
        filter: blur(.15em);
        opacity: .6;

        &::before {
            content: '';
            display: block;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image: linear-gradient(to bottom, var(--light-color), transparent);
            clip-path: polygon(25% 0, 75% 0, 100% 100%, 0% 100%);
            border-radius: 0 0 1em 1em;
        }
    }

    figure {
        display: block;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        transform-style: preserve-3d;
        perspective: var(--perspective);

        span {
            display: block;

            &::before {
                text-align: center;
                content: var(--text);
                white-space: pre;
                display: block;
            }
        }

        .text {
            animation: rotate 3s ease-in-out infinite both alternate;
            transform-style: preserve-3d;
            position: relative;
            font-size: 8vmin;/* 字体大小 */
            font-family: "华文琥珀";

            span {
                transform-style: preserve-3d;
                position: absolute;
                top: 0;
                left: 0;

                &:first-child {
                    position: static;
                    animation: shine 3s linear infinite;
                }

                @for $i from 1 through 20 {
                    &:nth-child(#{$i}) {
                        &::before {
                            transform: translateZ(#{$i * -.01}em);
                            color: hsl(var(--hue), #{60% - $i * 1%}, #{80% - $i * 2.5%});
                        }
                    }
                }
            }
        }

        .shadow {
            display: flex;
            align-items: center;
            justify-content: center;
            position: absolute;
            transform-style: preserve-3d;
            perspective: var(--perspective);
            width: 90vw;
            height: 90vw;
            font-size: .7em;/* 阴影字体大小 */
            font-family: "华文琥珀";
            transform: translate3D(0, 2em, 0) rotateX(90.01deg);
            opacity: 0.9;
            backface-visibility: hidden;

            &::after {
                content: '';
                display: block;
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background-image: radial-gradient(closest-side, var(--light-color), transparent);
                transform: translateY(1px);
                z-index: 0;
                mix-blend-mode: screen;
                opacity: 0.5;
            }

            &::before {
                filter: blur(4px);
                opacity: 0.8;

                // safari doesn't support filter over 3d-transform elements
                @media not all and (min-resolution:.001dpcm) {
                    filter: none;
                    opacity: 0.6;
                }

                animation: rotate-shadow 3s ease-in-out infinite both alternate;
                z-index: 1;
            }
        }
    }
}

@keyframes rotate {
    from {
        transform: rotate3D(0, 1, 0, calc(var(--spin) * -1)) rotateX(30deg);
    }

    to {
        transform: rotate3D(0, 1, 0, var(--spin)) rotateX(30deg);
    }
}

@keyframes rotate-shadow {
    from {
        transform: rotateZ(var(--spin));
    }

    to {
        transform: rotateZ(calc(var(--spin) * -1));
    }
}

@keyframes shine {
    0% {
        filter: brightness(1);
    }

    30% {
        filter: brightness(1.2);
    }

    50% {
        filter: brightness(1.4);
    }

    70% {
        filter: brightness(1.2);
    }

    100% {
        filter: brightness(1);
    }
}
</style>